#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <memory>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include "points_segmentation/image_labelers/radians.h"
#include "points_segmentation/image_labelers/abstract_image_labeler.h"

namespace depth_clustering
{

using std::array;
using cv::Mat;
using cv::Scalar;
using cv::Vec3b;

constexpr array<array<int, 3>, 200> AbstractImageLabeler::RANDOM_COLORS;

Mat AbstractImageLabeler::LabelsToColor(const Mat &label_image)
{
    Mat color_image(label_image.size(), CV_8UC3, Scalar(0, 0, 0));
    for (int row = 0; row < label_image.rows; ++row)
    {
        for (int col = 0; col < label_image.cols; ++col)
        {
            auto label = label_image.at<uint16_t>(row, col);
            auto random_color = AbstractImageLabeler::RANDOM_COLORS
            [label % AbstractImageLabeler::RANDOM_COLORS.size()];
            Vec3b color = Vec3b(random_color[0], random_color[1], random_color[2]);
            color_image.at<Vec3b>(row, col) = color;
        }
    }
    return color_image;
}

}  // namespace depth_clustering
